x
/// <reference path='typings/typescriptServices.d.ts' />/// <reference path='typings/codemirror.d.ts' />​module teapo {​ /** * Pubic API exposing access to TypeScript language services * (see its service property) * and handling the interfaces TypeScript requires * to access to the source code and the changes. */ export class TypeScriptService {​ /** Set of booleans for each log severity level. */ logLevels = { information: false, debug: false, warning: true, error: true, fatal: true };​ /** TypeScript custom settings. */ compilationSettings: ts.CompilerOptions = {};​ registry: ts.DocumentRegistry = null;​ /** Main public API of TypeScript compiler/parser engine. */ service: ts.LanguageService;​ /** Files added to the compiler/parser scope, by full path. */ scripts: { [fullPath: string]: TypeScriptService.Script; } = {};​ log: { logLevel: string; text: string; }[] = null; private _logLevel: string = null;​​ constructor() { this.registry = ts.createDocumentRegistry(); this.service = ts.createLanguageService(this._createLanguageServiceHost(), this.registry); }​ /** * The main API required by TypeScript for talking to the host environment. */ private _createLanguageServiceHost(): ts.LanguageServiceHost {​ return { getCurrentDirectory: () => '/', getDefaultLibFilename: () => '#lib.d.ts', getCancellationToken: () => null, getCompilationSettings: () => this.compilationSettings, getScriptFileNames: () => { var result = Object.keys(this.scripts).filter(k => this.scripts.hasOwnProperty(k)).sort(); //console.log('...getScriptFileNames():',result); return result; },